123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825 |
- <template>
- <div id="newsList">
- <!-- 页面头部 -->
- <HomePageHead></HomePageHead>
- <!-- 页面导航 -->
- <HomePageNavigation></HomePageNavigation>
- <!-- 广告1 -->
- <HomeAdvertising :imgurl="adImg1"></HomeAdvertising>
- <!-- 二级导航列表 -->
- <div class="nav2top" v-if="parent_name != ''"></div>
- <div class="nav2" v-if="parent_name != ''">
- <ul class="inner">
- <li class="home">
- <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
- </li>
- <li class="titleList" v-for="(item, index) in secondNav" :key="index">
- <NuxtLink :to="{ path: `/${item.aLIas_pinyin}/list-1.html` }">
- <span class="nav2_title">{{ item.alias }}</span>
- </NuxtLink>
- </li>
- </ul>
- </div>
- <div class="nav2btm" v-if="parent_name != ''"></div>
- <!-- 面包屑导航 -->
- <div class="breadcrumb">
- <div class="inner">
- <span class="location">当前位置:</span>
- <el-breadcrumb :separator-icon="ArrowRight">
- <el-breadcrumb-item>
- <NuxtLink to="/">首页</NuxtLink>
- </el-breadcrumb-item>
- <el-breadcrumb-item v-if="parent_name != ''">
- <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
- </el-breadcrumb-item>
- <el-breadcrumb-item>{{ name }}</el-breadcrumb-item>
- </el-breadcrumb>
- </div>
- </div>
- <!-- 资讯列表 -->
- <div class="newsList">
- <div class="inner">
- <div class="innerLeft">
- <ul class="list">
- <li v-for="(item, index) in newsList" :key="index">
- <NuxtLink :href="getLinkPathDetail(item)" :title="item.alias">
- <span class="listTitle">{{ item.title }}</span>
- <span class="time">{{ getTime(item.updated_at, 'month', 1) }}</span>
- </NuxtLink>
- </li>
- </ul>
- <!-- 分页器 -->
- <div class="pagination" v-if="total">
- <el-pagination size="small" background layout="prev, pager, next" :total="total" class="mt-4"
- v-model:page-size="pageSize" prev-text="上一页" next-text="下一页" :current-page="pageNum"
- @current-change="changePage" />
- </div>
- </div>
- <div class="innerRight">
- <DetailHotNews></DetailHotNews>
- <DetailHotNews2></DetailHotNews2>
- </div>
- </div>
- </div>
- <!-- 列表页广告二 -->
- <HomeAdvertising :imgurl="adImg2"></HomeAdvertising>
- <!-- 页面底部 -->
- <HomeFoot1></HomeFoot1>
- </div>
- </template>
- <script setup>
- import { onMounted } from 'vue';
- import { ElBreadcrumb, ElBreadcrumbItem, ElPagination, ElMessage } from 'element-plus'
- import { ArrowRight } from '@element-plus/icons-vue'
- // const nuxtApp = useNuxtApp();
- // const axios = nuxtApp.$axios;
- //1.获得路由id start ---------------------------------------->
- const route = useRoute();
- let articleId = 0;//路由id
- let pageNum = ref(2);
- let total = ref(1);
- let pageSize = ref(20);
- //获得当前的完整路径
- const fullPath = route.path;
- //拆分,取出来中间这一段,然后提取数字部分
- const segments = fullPath.split('/');
- const targetSegment = segments[1];
- //const numberPart = targetSegment.match(/\d+$/)?.[0];
- //let routeId = 20 //排除路径错误可以打开这个
- //通过导航路径反向查询导航id
- const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment,
- },
- });
- if (getRouteId.code == 200) {
- articleId = getRouteId.data.category_id
- } else {
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- console.log("错误位置:通过url路径查询导航池id")
- console.log("后端错误反馈:", getRouteId.message)
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- }
- //获得html前的数字
- // const pageUrl = segments[2];
- // const pageNumber = pageUrl.split('.')[0];
- // console.log("当前URL中的页码:")
- // console.log(pageNumber)//2
- // pageNum.value = parseInt(pageNumber);
- pageNum.value = parseInt(route.params.id);
- //1.获得路由id end ---------------------------------------->
- //2.页面数据 start ---------------------------------------->
- //2.2新闻列表
- const newsList = ref([]);
- let newslists = async () => {
- const listData = await requestDataPromise('/web/getWebsiteArticleList', {
- method: 'GET',
- query: {
- 'page': pageNum.value,
- 'pageSize': pageSize.value,
- 'catid': articleId
- },
- });
- if (listData.code == 200) {
- newsList.value = listData.data.rows;
- total.value = listData.data.count;
- console.log('news111111', newsList.value);
- } else {
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- console.log("错误位置:获取新闻列表")
- console.log("后端错误反馈1111:", listData.message)
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- }
- }
- //获得列表
- newslists();
- //分页事件
- let changePage = (value) => {
- console.log("当前页码", value);
- navigateTo(`/${targetSegment}/list-${value}.html`)
- }
- //2.3获得页面名称
- const name = ref('')
- let getPageName = async () => {
- const pageName = await requestDataPromise('/web/getOneWebsiteCategory', {
- method: 'GET',
- query: {
- 'catid': articleId
- },
- });
- if (pageName.code == 200) {
- name.value = pageName.data.alias
- } else {
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- console.log("错误位置:设置页面标题")
- console.log("后端错误反馈:", pageName.message)
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- }
- }
- //获得列表
- getPageName();
- //2.页面数据 end ---------------------------------------->
- //3.二级栏目 start ---------------------------------------->
- //3.1通过id获取父栏目
- const parent_name = ref([]);
- const parent_id = ref([]);
- const parent_pinyin = ref("");
- let getParentNav = async () => {
- const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
- method: 'GET',
- query: {
- 'catid': articleId
- },
- });
- if (listData.code == 200) {
- // console.log(111999)
- // console.log(listData.data);
- parent_name.value = listData.data.parent_name;
- parent_id.value = listData.data.parent_id;
- parent_pinyin.value = listData.data.parent_pinyin;
- } else {
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- console.log("错误位置:获取新闻列表")
- console.log("后端错误反馈:", listData.message)
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- }
- getSecondNav();
- }
- //获得父级栏目详情
- getParentNav();
- // 3.2获取二级栏目
- const secondNav = ref([]);
- let getSecondNav = async () => {
- const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'placeid': 1,
- 'pid': parent_id.value,
- 'num': 8,
- },
- });
- console.log('listData', listData);
- // secondNav.value = listData.data;
- if (listData.code == 200) {
- secondNav.value = listData.data;
- console.log('secondNav', secondNav.value);
- } else {
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- console.log("错误位置:获取新闻列表")
- console.log("后端错误反馈:", listData.message)
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- }
- }
- //3.二级栏目 end ---------------------------------------->
- //4.设置seo信息 start---------------------------------------->
- //4.1 设置seo信息
- const setData = await requestDataPromise('/web/getWebsiteCategoryHead', {
- method: 'GET',
- query: {
- 'catid': articleId
- },
- });
- if (setData.code == 200) {
- let seoTitle = setData.data.seo_title;
- let seoDescription = setData.data.seo_description;
- let seoKeywords = setData.data.seo_keywords;
- let seoSuffix = setData.data.suffix;
- let seoName = setData.data.website_name;
- useSeoMeta({
- title: seoTitle + "_" + seoName + "_" + seoSuffix,
- meta: [
- { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
- { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
- ]
- });
- } else {
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- console.log("错误位置:设置列表页面SEO数据")
- console.log("后端错误反馈:", setData.message)
- console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
- }
- //4.设置seo信息 end---------------------------------------->
- //5.广告 start---------------------------------------->
- let adImg1 = ref({});
- let adImg2 = ref({});
- onMounted(async () => {
- //从客户端获取行政职能部门 加快打开速度
- const { $webUrl, $CwebUrl } = useNuxtApp();
- //广告1
- let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_list_0001`
- const responseAd1 = await fetch(url, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd1 = await responseAd1.json();
- adImg1.value = resultAd1.data[0];
- console.log('adImg1', adImg1.value);
- //广告2
- let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_list_0002`
- const responseAd2 = await fetch(url2, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd2 = await responseAd2.json();
- adImg2.value = resultAd2.data[0];
- })
- //5.广告 end---------------------------------------->
- // 6.跳转 start ---------------------------------------->
- const getLinkPathDetail = (item) => {
- if (item.islink == 1) {
- return `${item.linkurl}`;
- } else {
- return `/${item.pinyin}/${item.id}.html`;
- }
- }
- // 6.跳转 end ---------------------------------------->
- </script>
- <style lang="less" scoped>
- #newsList {
- width: 100%;
- overflow: hidden;
- }
- .nav2top {
- width: 1250px;
- height: 3px;
- margin: 0 auto;
- background-color: #a01c0e;
- }
- .nav2btm {
- width: 1200px;
- height: 3px;
- margin: 0 auto;
- background-color: #a01c0e;
- }
- .nav2 {
- width: 100%;
- height: 48px;
- background-color: #a01c0e;
- .inner {
- width: 1250px;
- height: 48px;
- line-height: 48px;
- padding: 0 45px;
- margin: 0 auto;
- box-sizing: border-box;
- display: flex;
- // justify-content: space-between;
- .titleList {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: bold;
- font-size: 14px;
- color: #FFFFFF;
- .nav2_title {
- display: inline-block;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: bold;
- font-size: 14px;
- color: #FFFFFF;
- }
- a {
- padding: 0 38px;
- color: #FFFFFF;
- border-left: 1px solid #7E1C11;
- }
- //鼠标点击后的样式
- .nav2_title_active {
- display: inline-block;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: bold;
- font-size: 14px;
- color: #FFFFFF;
- border-bottom: 1px solid #FFFFFF;
- }
- }
- .titleList:hover {
- a {
- color: #a01c0e;
- .nav2_title {
- border-bottom: 1px solid #FFFFFF;
- }
- }
- }
- .home {
- width: 100px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: bold;
- font-size: 14px;
- color: #F8ECD2;
- a {
- color: #F8ECD2;
- margin-right: 39px;
- }
- }
- }
- }
- //导航条
- .breadcrumb {
- width: 100%;
- height: 22px;
- margin-bottom: 30px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- margin-top: 40px;
- :deep(.el-breadcrumb) {
- display: inline-block;
- vertical-align: -4px;
- }
- :deep(.el-breadcrumb__inner a),
- :deep(.el-breadcrumb__inner.is-link) {
- color: #666666;
- font-weight: 400;
- text-decoration: none;
- transition: var(--el-transition-color);
- }
- span {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- span:hover {
- color: #666666;
- }
- .location {
- margin-right: 20px;
- width: 100px;
- height: 22px;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #666666;
- line-height: 23px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- }
- // 资讯列表
- .newsList {
- width: 100%;
- // height: 675px;
- overflow: hidden;
- margin-bottom: 70px;
- .inner {
- width: 1200px;
- .innerLeft,
- .innerRight {
- border-top: 1px solid #ccc;
- }
- .innerLeft {
- width: 820px;
- margin-right: 30px;
- .list {
- margin-bottom: 70px;
- li {
- width: 820px;
- padding: 15px 0;
- a {
- display: flex;
- justify-content: space-between;
- }
- .listTitle {
- // float: left;
- display: inline-block;
- width: 486px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 20px;
- color: #333333;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- .time {
- // float: right;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 18px;
- color: #333333;
- }
- }
- >li:hover .listTitle {
- color: #a01c0e;
- }
- >li:nth-child(5n) {
- border-bottom: 1px solid #D9D9D9;
- padding-bottom: 30px;
- }
- >li:nth-child(5n+1) {
- span {
- font-weight: bold;
- }
- font-weight: bold;
- padding-top: 30px;
- }
- }
- >.pagination {
- width: 800px;
- height: 34px;
- margin-left: 141px;
- display: flex;
- justify-content: center;
- margin: 0;
- // 鼠标移入后字体颜色
- .el-pagination::v-deep :hover {
- color: #a01c0e;
- }
- .el-pagination.is-background::v-deep .btn-next,
- .el-pagination.is-background::v-deep .btn-prev {
- width: 70px;
- height: 34px;
- margin: 0px 10px;
- border-radius: 4px;
- }
- .el-pagination.is-background::v-deep .el-pager li {
- margin: 0px 10px;
- width: 38px;
- height: 34px;
- border-radius: 4px;
- }
- .el-pagination.is-background::v-deep .btn-next.is-active,
- .el-pagination.is-background::v-deep .btn-prev.is-active,
- .el-pagination.is-background::v-deep .el-pager li.is-active {
- background-color: #a01c0e;
- color: #fff;
- }
- }
- }
- .innerRight {
- width: 350px;
- height: 1242px;
- border-bottom: 1px solid #ccc;
- // height: 605px;
- }
- }
- }
- //资讯推荐
- .zixuntuijian {
- width: 100%;
- height: 290px;
- margin-bottom: 70px;
- .innerLeft {
- // 左侧
- .zixunLeft {
- margin-right: 30px;
- }
- .zixunRight,
- .zixunLeft {
- float: left;
- width: 380px;
- height: 290px;
- // 标题部分
- >.title {
- width: 380px;
- }
- >.title>h3 {
- height: 36px;
- font-family: Source Han Sans, Source Han Sans;
- font-weight: bold;
- font-size: 24px;
- color: #000000;
- line-height: 28px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- border-bottom: 1px solid #a01c0e;
- }
- >.title>h3>span {
- float: right;
- width: 56px;
- height: 20px;
- line-height: 24px;
- font-weight: 400;
- font-size: 14px;
- color: #999999;
- font-style: normal;
- text-transform: none;
- }
- .photo_text {
- >li:first-child {
- width: 380px;
- height: 120px;
- margin-top: 20px;
- margin-bottom: 15px;
- position: relative;
- >img {
- float: left;
- width: 160px;
- height: 120px;
- }
- >div {
- float: left;
- width: 220px;
- height: 120px;
- padding-left: 15px;
- padding-top: 6px;
- box-sizing: border-box;
- background-color: #f6f6f6;
- >h5 {
- width: 200px;
- height: 54px;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-overflow: ellipsis;
- word-break: break-all;
- font-family: Source Han Sans, Source Han Sans;
- font-weight: 500;
- font-size: 18px;
- color: #333333;
- line-height: 26px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- >p {
- width: 200px;
- height: 22px;
- line-height: 20px;
- position: absolute;
- bottom: 5px;
- right: 0;
- >span {
- display: inline-block;
- // width: 100px;
- height: 18px;
- font-family: Source Han Sans, Source Han Sans;
- font-weight: 400;
- font-size: 12px;
- color: #999999;
- text-align: left;
- line-height: 14px;
- font-style: normal;
- text-transform: none;
- }
- >span:last-child {
- // width: 90px;
- text-align: right;
- margin-left: 20px;
- }
- }
- }
- }
- >li {
- width: 380px;
- height: 25px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 18px;
- color: #333333;
- line-height: 21px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- margin-bottom: 10px;
- em {
- display: inline-block;
- width: 8px;
- height: 8px;
- border-radius: 8px;
- margin-right: 10px;
- background-color: #d9d9d9;
- }
- }
- >li:hover {
- color: #a01c0e;
- }
- >li:hover em {
- background-color: #a01c0e;
- }
- }
- }
- }
- .innerRight {
- width: 381px;
- height: 290px;
- background-color: #fbfbfb;
- >.title {
- width: 380px;
- height: 40px;
- line-height: 40px;
- border-top: 1px solid #a01c0e;
- border-bottom: 1px solid #e7e7e7;
- >h4 {
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- margin-left: 20px;
- font-size: 20px;
- color: #000000;
- text-align: left;
- font-style: normal;
- text-transform: none;
- >span {
- float: right;
- font-family: Microsoft YaHei, Microsoft YaHei;
- font-weight: 400;
- font-size: 14px;
- margin-right: 10px;
- color: #999999;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- }
- }
- .rightList {
- height: 540px;
- margin-top: 20px;
- >li {
- height: 100px;
- margin-bottom: 10px;
- >img {
- width: 150px;
- height: 100px;
- }
- >p {
- width: 219px;
- height: 100px;
- padding-left: 12px;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 16px;
- color: #333333;
- line-height: 22px;
- text-align: left;
- font-style: normal;
- text-transform: none;
- }
- >p:hover {
- box-shadow: 0 0 16px 1px rgba(0, 0, 0, 0.1);
- }
- }
- }
- }
- }
- </style>
|